/*
 *
 */
package org.jiscinvolve.astrodabis.barberry.common.core;

import org.jiscinvolve.astrodabis.barberry.common.data.RowTag;
import org.jiscinvolve.astrodabis.barberry.common.data.JoinTag;

/**
 *
 */
public interface Tag
extends Identified, Tracked, Owned, Deletable
    {

    public static final String NAME_CHARSET = "a-z0-9.-" ;
    public static final String NAME_INCLUDE = "["  + NAME_CHARSET + "]+" ;
    public static final String NAME_EXCLUDE = "[^" + NAME_CHARSET + "]+" ;
    public static final String NAME_REPLACE = "-" ;
    public static final String NAME_EXPLAIN = "Tag names may only contain lowercase alphanumeric characters (a-z and 0-9), dot '.' or dash '-'" ;

    public interface Factory
        {

        public String clean(String string);

        public Identifier ident(String ident);

        public Tag create(Account owner, String name);
        public Tag createQuick(Account owner, String name);

        public Tag create(Account owner, String name, String text);
        public Tag createQuick(Account owner, String name, String text);

        public Iterable<Tag> select();

        public Tag select(Identifier ident);

        public Iterable<Tag> select(String name);

        public Iterable<Tag> select(Account owner);

        public Iterable<Tag> select(Job job);

        public Tag select(Account owner, String name);

        public void update(Tag tag);
        public void delete(Tag tag);

        public Iterable<Tag> recent(int limit);
        public Iterable<Tag> recent(Account owner, int limit);

        }

    public String name();

    public String text();

    public void text(String text);

    public interface RowTags
        {

        public long count();

        public Iterable<RowTag> select();

        }

    public RowTags rowtags();


    public interface JoinTags
        {

        public long count();

        public Iterable<JoinTag> select();

        }

    public JoinTags jointags();

    public interface Jobs
        {

        public Iterable<Job> rowtags();
        public Iterable<Job> jointags();

        }

    public Jobs jobs();

    }

